#include <httplib.h>

void HelloWorld(const httplib::Request &req, httplib::Response &rsp) {
    std::cout << req.method << std::endl;
    std::cout << req.path << std::endl;
    std::cout << req.body << std::endl;
    for (auto it : req.headers) {
        std::cout << it.first << " = " << it.second << std::endl;
    }
    for (auto it : req.params) {
        std::cout << it.first << " = " << it.second << std::endl;
    }
    std::string html_body = "<html><body><h1>Hello World</h1></body></html>";
    rsp.set_content(html_body, "text/html");
    rsp.status = 200; 
    return;
}

int main()
{
    httplib::Server svr;
    svr.set_base_dir("./wwwroot");
    svr.Get("/hi", HelloWorld);
    svr.Get(R"(/numbers/(\d+))", [](const httplib::Request &req, httplib::Response &rsp){
        std::cout << req.method << std::endl;
        std::cout << req.path << std::endl;
        for (auto it : req.matches) {
            std::cout << it << std::endl;
        }
    });
    svr.listen("0.0.0.0", 9000);
    return 0;
}